package com.douqu.game.core.entity.sprite;

import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.entity.Skill;
import com.douqu.game.core.factory.ConstantFactory;
import com.douqu.game.core.factory.DataFactory;

import java.util.Arrays;

/**
 * Created by bean on 2017/7/26.
 */
public class PlayerLv extends GameObject{

    /** 需要的经验值 */
    public int exp;

    /** 攻击力 */
    public int physicsAtk;

    public int punctureAtk;

    public int magicAtk;

    public int physicsDef;

    public int punctureDef;

    public int magicDef;

    /** 力量 */
    public int power;
    /** 敏捷 */
    public int agility;
    /** 智力 */
    public int wisdom;

    /** 生命 */
    public int hp;

    public Skill defaultSkill;

    /** 增加的技能列表 */
    public Skill[] cdSkills;

    /** 当前能携带进战斗的兵种数量 */
    public int battleSoldierCount;


    @Override
    public void setVariable(String key, String value)
    {
        if("cdSkills".equals(key))
        {
            String[] ids = value.split(ConstantFactory.SEMICOLON);
            cdSkills = new Skill[ids.length];
            for(int i = 0; i < ids.length; i++)
            {
                cdSkills[i] = DataFactory.getInstance().getGameObject(DataFactory.SKILL_KEY, Integer.parseInt(ids[i]));
                if(cdSkills[i] == null)
                {
                    System.out.println("Load PlayerLv cdSkills is Null:" + ids[i]);
                }
            }
        }
        else if("defaultSkill".equals(key))
        {
            this.defaultSkill = DataFactory.getInstance().getGameObject(DataFactory.SKILL_KEY, Integer.parseInt(value));
            if(defaultSkill == null)
            {
                System.out.println("Load PlayerLv defaultSkill is Null:" + value);
            }
        }
        else
            super.setVariable(key, value);
    }


    @Override
    public String toString() {
        return "PlayerLv{" +
                "exp=" + exp +
                ", physicsAtk=" + physicsAtk +
                ", punctureAtk=" + punctureAtk +
                ", magicAtk=" + magicAtk +
                ", physicsDef=" + physicsDef +
                ", punctureDef=" + punctureDef +
                ", magicDef=" + magicDef +
                ", power=" + power +
                ", agility=" + agility +
                ", wisdom=" + wisdom +
                ", hp=" + hp +
                ", defaultSkill=" + defaultSkill +
                ", cdSkills=" + Arrays.toString(cdSkills) +
                ", battleSoldierCount=" + battleSoldierCount +
                "} " + super.toString();
    }
}
